package com.zcy.utils;

import com.zcy.model.Brand;
import com.zcy.model.Cell;
import com.zcy.model.Layer;

public class LayerUtils {
    public static Layer builderLayer(Integer rowNum,Integer colNum){
        //实例化Layer对象
        Layer layer = new Layer(rowNum,colNum);
        //获取卡牌数组
        Brand[] brands = BrandUtils.builderBrand(layer.getCapacity());
        //获取格子数组
        Cell[][] cells = layer.getCells();

        int flag = 0 ;
        for (int row = 0;row < cells.length;row++){
            for (int col = 0;col < cells[row].length;col++){
                Brand brand = brands[flag++];
                //实例化格子对象
                Cell cell = new Cell();
                //属性复制
                cell.setState(1);
                //互相建立关联
                cell.setBrand(brand);
                brand.setCell(cell);
                //赋值
                cells[row][col] = cell;
            }
        }
        return layer;
    }
}
